package com.karson.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.karson.common.model.StorageConfig;
import com.karson.common.response.CommonResult;
import com.karson.service.service.IStorageConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ZKS
 */
@RestController
@RequestMapping("/api/storage")
@Tag(name = "存储配置管理接口")
public class StorageController {

    @Autowired
    private IStorageConfigService storageConfigService;

    @Operation(summary = "配置列表")
    @GetMapping("/getConfigByType")
    public CommonResult<StorageConfig> getConfigByType(@RequestParam String type) {
        return CommonResult.success(storageConfigService.getStorageConfigByType(type));
    }
    @Operation(summary = "更新配置")
    @PostMapping("/update")
    public CommonResult<String> isEdit(@RequestBody @Validated StorageConfig storageConfig) {
        storageConfigService.updateStorageConfig(storageConfig);
        return CommonResult.success();
    }
}
